BEGIN {
  FS = ","
  OFS = ","
}
{
#  if (NR == 1)
#    print "Year", "Region", "Employment", "EGR"
#    print "Year", "Region", "Wage", "WGR"
  region = $1
  year = $4

  wage[region,year] += $5
  gr[region,year] += $NF
  counts[region,year] ++

}

END {
  for (year = 2002; year <= 2011; ++year) {
      for (region = 0; region < 3; ++region){
        print region, year, wage[region,year]/counts[region,year], gr[region,year]/counts[region,year], counts[region,year]

#  (key in gr) {
      #   split (key, region_year, SUBSEP)
      #  print region_year[1], region_year[2], gr[key]/counts[key], counts[key]
    }
  }
}

